﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BTSDecompress.Controls;
namespace BTSDecompress
{
    public partial class fdlgUnsavedQueries : Form
    {
        Hashtable _unsavedQueries;
        Hashtable _storeUnsavedQueries;
        public fdlgUnsavedQueries()
        {
            InitializeComponent();
        }
        public fdlgUnsavedQueries(Hashtable unsavedQueries)
        {
            InitializeComponent();
            UnsavedQueries = unsavedQueries;
        }
        public Hashtable StoreUnsavedQueries
        {
            get { return _storeUnsavedQueries; }
            set { _storeUnsavedQueries = value; }
        }
        public Hashtable UnsavedQueries
        {
            get { return _unsavedQueries; }
            set { _unsavedQueries = value; }
        }
        private void LoadUnsavedQueries()
        {
            foreach (DictionaryEntry entry in UnsavedQueries)
            {
                QueryControl queryControl = (QueryControl)entry.Value;
                ListViewItem item = new ListViewItem(queryControl.CurrentFile);
                unSavedQueriesListView.Items.Add(item);
            }
        }
        private void Store()
        {
            StoreUnsavedQueries = new Hashtable();
            if (unSavedQueriesListView.SelectedItems.Count != 0)
            {
                foreach (ListViewItem item in unSavedQueriesListView.SelectedItems)
                {
                    QueryControl queryControl = (QueryControl)UnsavedQueries[item.Text];
                    StoreUnsavedQueries.Add(item.Text, queryControl);
                }
            }
            else
            {
                StoreUnsavedQueries = UnsavedQueries;
            }
        }
        private void fdlgUnsavedQueries_Load(object sender, EventArgs e)
        {
            LoadUnsavedQueries();
        }
        private void yesButton_Click(object sender, EventArgs e)
        {
            Store();
        }
    }
}
